#include "zf_common_headfile.h"


// 创建窗口标题
// std::string windowTitle = std::to_string(Picture_Count);
// 创建窗口标题
std::string windowTitle = "Image";

cv::Mat image;
cv::Mat image_resized;
// 鼠标事件回调函数  
void mouseHandler(int event, int x, int y, int flags, void* param) {
    CV_UNUSED(flags);
    CV_UNUSED(param);
    if (event == cv::EVENT_LBUTTONDOWN) {
        uchar pixel = Gray_Image[y][x];
        std::cout << "Pixel at (" << x << ", " << y << "): " << (int)pixel <<std::endl;
        // std::cout<< Diff_Ratio(Gray_Image[y][x-COL_STEP] , Gray_Image[y-10][x-COL_STEP]) <<std::endl;
// std::cout<<detect_icurvity(y,5,20,0)<<std::endl;
    }
}




int main()
{
Data_Settings();


while(Picture_Count<=2663) //2663
{
// std::string filePath = "D:/SmartCar_tutorial/road_element/circle_l/" + std::to_string(Picture_Count) + ".jpg";
std::string filePath = "D:/SmartCar_tutorial/road_element/road1/" + std::to_string(Picture_Count) + ".jpg";
// std::string filePath = "D:/SmartCar_tutorial/road_element/road0/" + std::to_string(Picture_Count) + ".jpg";

// std::string filePath = "D:/SmartCar_tutorial/road_element/garage/" + std::to_string(Picture_Count) + ".jpg";
image = cv::imread(filePath, cv::IMREAD_GRAYSCALE);
cv::resize(image, image_resized, cv::Size(MT9V03X_W,MT9V03X_H), 0, 0, cv::INTER_AREA);
OpenCV_Transfer(mt9v03x_image,image_resized);//模拟源图像数组mt9v03x_image

/*****************************************************************************/
                    ImageProcess();
/*****************************************************************************/



// longest_row(Gray_Image[0],Image_DataStruct.begin_x,5,1);
/*********************debug层***************************/
OpenCV_Inverse();//将数组图像在切换为彩色图像
// if(System_DataStruct.CIRCLE_Flag == CIRCLE_PREV_D_M)
// {
draw_maze(0);
draw_maze(1);
// }


    //理论中线 line (col,row)
cv::line(colorImage, cv::Point(COL/2, 0), cv::Point(COL/2,ROW-1),cv::Scalar(255,0,0),1);


 //if(System_DataStruct.CIRCLE_Flag==CIRCLE_WILL_IN  || System_DataStruct.CIRCLE_Flag==CIRCLE_TURN_D)
//  {
     for (uint8_t i = 0; i < sizeof(white_col); i++)
     {
         if(white_col[i]==0)continue;
         cv::line(colorImage, cv::Point(i, ROW-1), cv::Point(i,ROW-white_col[i]),cv::Vec3b(255,150, 200),1,cv::LINE_4);
     }
    
//  }

//最长白列
cv::line(colorImage, cv::Point(Image_DataStruct.begin_x, ROW-1), cv::Point(Image_DataStruct.begin_x,ROW-Image_DataStruct.lst_rows),cv::Vec3b(180,20, 240),1,cv::LINE_4);
    cv::namedWindow(windowTitle,cv::WINDOW_NORMAL); // 创建窗口
  //  cv::resizeWindow("Image", colorImage.cols, colorImage.rows); // 根据图像尺寸调整窗口大小

    cv::imshow(windowTitle,colorImage);
    cv::setMouseCallback(windowTitle, mouseHandler,(void*)&colorImage);
    cv::waitKey(0);//确保窗口保持打开状态
    Picture_Count+=1;

}


}

